package me.zhengjie.modules.system.service.apply;

import cn.hutool.json.JSONUtil;
import me.zhengjie.exception.CommonUtilException;
import me.zhengjie.modules.system.domain.WxUser;
import me.zhengjie.modules.system.enums.ApplyWorkOrderTypeEnum;
import me.zhengjie.modules.system.service.WxUserService;
import me.zhengjie.modules.system.service.dto.DisChangeApplyDto;
import me.zhengjie.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class InitTicketNumServiceImpl implements IApplyCallbackService{

    @Autowired
    WxUserService wxUserService;
    @Override
    public Integer getApplyType() {
        return ApplyWorkOrderTypeEnum.InitTicketNum.getType();
    }

    @Override
    public boolean execute(DisChangeApplyDto applyDto) {
        String json = applyDto.getApplyContent();
        if(StringUtils.isEmpty(json)){
            throw new CommonUtilException("申请内容不能为空");
        }
        WxUser wxUser = JSONUtil.toBean(json, WxUser.class);
        wxUserService.update(wxUser);
        return true;
    }
}
